const { Sequelize, DataTypes } = require("sequelize")

//数据库配置对象
const config = {
    host: "localhost", //主机名
    database: "petdb", //使用的哪个数据库名
    username: "root", //mysql账号
    password: "038826", //mysql密码
    port: 3306, //端口号，mysql默认端口为3306
}

//sequelize的实例化
const sequelize = new Sequelize(
    config.database,
    config.username,
    config.password, {
        host: config.host,
        dialect: "mysql", //方言：针对不同的数据库
        pool: {
            max: 5, //连接池最大连接数量
            min: 0, //最小连接数量
            idle: 10000, // 如果一个线程10秒内没有被使用过，就释放
        },
        logging: true, //输出日志
    }
)

const OrderModel = require('./model/order')(sequelize, DataTypes);
const CatModel = require('./model/cat')(sequelize, DataTypes);
const UserModel = require('./model/user')(sequelize, DataTypes);
const DogModel = require('./model/dog')(sequelize, DataTypes);
const GoodsModel = require('./model/goods')(sequelize, DataTypes);
const NoticeModel = require('./model/notice')(sequelize, DataTypes);

module.exports = { sequelize, OrderModel, CatModel, GoodsModel,UserModel,NoticeModel, DogModel } //导出出去